package com.fnic.wifi.threadLocal.hibernate;
public class HibernateUtil {

    //创建线程局部变量session，用来保存Hibernate的Session
    public static final ThreadLocal<Integer> session = new ThreadLocal<Integer>();
    
    public static Integer s2=0;
 
    /**
     * 获取当前线程中的Session
     * @return Session
     * @throws HibernateException
     */
    public static Integer currentSession()  {
        Integer s =   session.get();
        if (s == null) {
            s = 0;
            session.set(s);         
        }
        s++;
        session.set(s);         
        return s;
    }
    
    /**
     * 获取当前线程中的Session
     * @return Session
     * @throws HibernateException
     */
    public static Integer currentSessionError()  {
        return s2++;
    }
}